package com.kai.mqtt.data;

import com.kai.mqtt.enums.ErrorCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * @author weijk
 * @since 2024/7/1
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class PageResult<T> extends Result<List<T>> {

    private long pageIndex;

    private long pageSize;

    private long total;

    public PageResult(List<T> body, long pageIndex, long pageSize, long total) {
        super(body, ErrorCodeEnum.SUCCESS.getCode(), ErrorCodeEnum.SUCCESS.getMsg(), true);
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.total = total;
    }

    public static <T> PageResult<T> success(List<T> body, long pageIndex, long pageSize, long total) {
        return new PageResult<>(body, pageIndex, pageSize, total);
    }
}
